const fs = require('fs');
const path = require('path');

// 获取传入的参数（要求release, debug或reset）
const buildMode = process.argv[2];

// 检查参数是否正确
if (!buildMode || (buildMode !== 'release' && buildMode !== 'debug')) {
    console.error('[ERROR] Usage: node script.js <release|debug>');
    process.exit(1);
}

// 获取CMakeLists文件所在的路径
const CMakeListsDirPath = path.join(
    __dirname,
    '..',
    'harmony',
    'entry',
    'src',
    'main',
    'cpp',
);

// 获取CMakeLists-debug | CMakeLists-release文件路径
const CMakeListsReplacePath = path.join(CMakeListsDirPath, `CMakeLists-${buildMode}.txt`);
// 获取CMakeLists文件路径
const CMakeListsPath = path.join(CMakeListsDirPath, 'CMakeLists.txt');
// 获取CMakeLists-debug | CMakeLists-release文件内容
const CMakeListsReplaceContent = fs.readFileSync(CMakeListsReplacePath, 'utf-8');
// 将CMakeLists-debug | CMakeLists-release文件内容写入CMakeLists文件
fs.writeFileSync(CMakeListsPath, CMakeListsReplaceContent);

